package fr.mma.scrumm.factory;

import fr.mma.scrumm.dto.SprintDTO;
import fr.mma.scrumm.dto.StoryDTO;
import fr.mma.scrumm.model.Sprint;

public class SprintFactory extends AbstactFactory<SprintDTO, Sprint> {
	
	StoryFactory storyFactory = new StoryFactory();

	public SprintDTO build(Sprint sprint) {
		SprintDTO sprintDto = new SprintDTO();
		sprintDto.setId(sprint.getId());
		sprintDto.setUrl("rest/sprint/"+sprint.getKey());
		sprintDto.setStories(storyFactory.build(sprint.getStories()));
		int nombrePoint = 0;
		for (StoryDTO story : sprintDto.getStories()) {
			nombrePoint += story.getEstimation();
		}
		sprintDto.setTotalPoint(nombrePoint);
		return sprintDto;
	}

}
